<%= simple_form_for(@order) do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

<div class="form-inputs">
	<%= f.input :order_code, label: '订单号' %>
	<%= f.association :customer, label_method: :company, value_method: :id , label: '客户' %>
	<%= f.input :customer_po, label: '客户ERP号' %>
	<%= f.input :po_date, label: '客户订单日期' %>
	<%= f.input :due_date, label: '交期' %>
	<%= f.input :amount , label: '金额'%>
	<%= f.input :comment, label: '备注' %>

	<br  />
	<br class="">

	<% if url_for(only_path: true, action: 'new').eql?(request.original_fullpath) %>
	<table class="table table-hover table-sm">
		<thead>
			<tr>
				<th>产品名称</th>
				<th>数量</th>
				<th>价格</th>
				<th></th>
			</tr>
		</thead>
		<tbody>
			<%= f.simple_fields_for :items do |builder| %>
			<%= render 'item_fields', f:builder %>
			<% end %>
		</tbody>
	</table>

	<p>
		<%= link_to_add_fields '增加产品', f, :items %>
	</p>

	<% end %>
</div>

<div class="form-actions">
	<%= f.button :submit, '提交',class: "btn-primary" %>
</div>
<% end %>
